<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="所属区县" prop="orgCode">
        <el-cascader v-model="orgCodeList" @change="orgCodeChange" :options="options" :show-all-levels="false" :props="{ checkStrictly: true,value: 'code',label: 'name',children: 'chridrenList' }" clearable></el-cascader>
      </el-form-item>
      <el-form-item label="维护站名称" prop="vehicleServiceName">
        <el-select v-model="queryParams.vehicleServiceName" filterable clearable placeholder="请选择维护站名称">
          <el-option
            v-for="item in wxUnitList"
            :key="item"
            :label="item"
            :value="item">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="维护站编号" prop="wxCode">
        <el-input
          v-model="queryParams.wxCode"
          placeholder="请输入维护站编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table  border v-loading="loading" :data="logList">
      <el-table-column label="序号" align="center" type="index" />
      <el-table-column label="维护站名称" align="center" prop="vehicleServiceName" width="180" :show-overflow-tooltip="true"/>
      <el-table-column label="统一社会信用编码" width="130" align="center" prop="socialUniformCode" />
      <el-table-column label="审核人" align="center" prop="approver" />
      <el-table-column label="区划编码" align="center" prop="orgCode" />
      <el-table-column label="所属区县" align="center" prop="orgName" width="180"/>
      <el-table-column label="审核结果" align="center" prop="approvalResult">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.approvalResult === '0'">同意</el-tag>
          <el-tag type="danger" v-if="scope.row.approvalResult === '1'">不同意</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="审核意见" align="center" prop="approvalComments" width="180" :show-overflow-tooltip="true"/>
      <el-table-column label="审核时间" align="center" prop="approvalTime" width="180" :show-overflow-tooltip="true"/>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { toExamineLogList } from '@/api/maintenanceenterprise/toexamine';
import { siteNameList } from '@/api/maintenanceenterprise/secondarysite';
import { getDistrictTreeList } from "@/api/system/district";
export default {
  name: "Secondary",
  data() {
    return {
      orgCodeList: [],
      examineOpen: false,
      openSiteData: false,
      wxUnitList: [],
      toExamineLogList: {},
      props: {
        label: "name",
        value: "code",
        children: "chridrenList"
      },
      options: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 汽车检测-二级维护站表格数据
      logList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        wxCode: null,
        wxUnit: "",
        wxAddr: null,
        wxPerson: null,
        wxTel: null,
        creditCode: null,
        legalPerson: null,
        legalTel: null,
        orgCode: null,
        enterpriseType: null
      },
      // 表单参数
      form: {},
      examineParam: {},
    };
  },
  created() {
    this.getList();
    this.getDistrictTreeList();
    this.getSiteNameList();
  },
  methods: {
    getDistrictTreeList(){
      getDistrictTreeList().then(res => {
        this.options = res.data
      })
    },
    getSiteNameList() {
      this.queryParams.orgCode = this.orgCodeList[this.orgCodeList.length - 1];
      siteNameList(this.queryParams).then(res => {
        this.wxUnitList = res.data;
      })
    },
    orgCodeChange(){
      this.queryParams.orgCode = this.orgCodeList[this.orgCodeList.length - 1];
      siteNameList(this.queryParams).then(res => {
        this.wxUnitList = res.data;
      })
    },
    /** 查询汽车检测-二级维护站列表 */
    getList() {
      this.loading = true;
      this.queryParams.orgCode = this.orgCodeList[this.orgCodeList.length - 1];
      toExamineLogList(this.queryParams).then(response => {
        this.logList = response.records;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        wxCode: null,
        wxUnit: null,
        wxAddr: null,
        wxPerson: null,
        wxTel: null,
        creditCode: null,
        licensepic: null,
        legalPerson: null,
        legalTel: null,
        businessScope: null,
        orgCode: null,
        createTime: null,
        updateTime: null,
        measurementTestingCertificate: null,
        workstation: null,
        certificateStartDate: null,
        certificateEndDate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.queryParams.orgCode) {
        this.queryParams.orgCode = this.queryParams.orgCode[this.queryParams.orgCode.length - 1];
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.orgCodeList = []
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
